// 滚动到 上次访问位置
const scrollToView = () => {
    let scrollHeight = localStorage.getItem('scrollHeight');
    if(scrollHeight) {
        setTimeout(() => {
            window.scrollTo({
                top: scrollHeight,
                behavior: "smooth"
            });
        }, 300)
    }
}
// 监听用户滚动位置
const listenScrollTop = () => {
    const debounce = () => {
        let timer = null;
        return () => {
            if(timer) {
                clearTimeout(timer);
            }
            timer = setTimeout(() => {
                localStorage.setItem('scrollHeight', window.pageYOffset ||
                    document.body.scrollTop || document.documentElement.scrollTop)
            }, 500)
        }
    }
    this.scrollFn = debounce();
    window.addEventListener('scroll', this.scrollFn)
}
